<template>
  <div>
    <div class="headsbtn">
      <div>
        <h2>面签审核:{{ tableData.custName }}</h2>
      </div>
      <el-row>
        <el-col :span="4">
          <el-button type="primary" @click="gohome()" size="mini"
            >返回</el-button
          >
        </el-col>
        <el-col :span="6">
          <el-button type="primary" @click="limits()" size="mini">
            <span v-if="sqrored(tableData.applCde)">额度信息</span>
            <span v-else>申请人信息</span></el-button
          >
        </el-col>

        <el-col :span="5">
          <el-button type="primary" @click="riskbtn()" size="mini"
            >风险提示</el-button
          >
        </el-col>
        <el-col :span="5">
          <el-button type="primary" @click="creditbtn(formInline)" size="mini"
            >征信报告</el-button
          >
        </el-col>
        <el-col :span="4">
          <el-button type="primary" @click="goback()" size="mini"
            >挂起</el-button
          >
        </el-col>
      </el-row>
    </div>
    <el-divider></el-divider>
    <!-- 面签 -->
    <div style="display: flex; width: 95%;margin: 0 auto;">
      <div style="width: 80%;">
        <!-- 左 -->
        <el-row>
          <el-col :span="8">
            本人面签（必填项）
          </el-col>
          <el-col :span="12">
            <el-radio v-model="mqInfo.selfFaceSign" label="1"
              >面签通过</el-radio
            >
            <el-radio v-model="mqInfo.selfFaceSign" label="2"
              >面签不通过</el-radio
            >
            <el-radio v-model="mqInfo.selfFaceSign" label="3">未决项</el-radio>
          </el-col>
        </el-row>
        <el-row class="elrowmagtop">
          <el-col :span="8">
            备注：
          </el-col>
          <el-col :span="4">
            <el-input
              type="textarea"
              :rows="2"
              v-model="mqInfo.selfFaceSignRemark"
            >
            </el-input>
          </el-col>
        </el-row>
        <el-row class="elrowmagtop">
          <el-col :span="8">
            第三方电核（必填项）
          </el-col>
          <el-col :span="12">
            <el-radio v-model="mqInfo.thdTeleConfirm" label="1"
              >电核一致</el-radio
            >
            <el-radio v-model="mqInfo.thdTeleConfirm" label="2"
              >电核不一致</el-radio
            >
            <el-radio v-model="mqInfo.thdTeleConfirm" label="3"
              >未决项</el-radio
            >
          </el-col>
        </el-row>
        <el-row class="elrowmagtop">
          <el-col :span="8">
            备注：
          </el-col>
          <el-col :span="4">
            <el-input
              type="textarea"
              :rows="2"
              v-model="mqInfo.thdTeleConfirmRemark"
            >
            </el-input>
          </el-col>
        </el-row>
        <el-row class="elrowmagtop">
          <el-col :span="8">
            其他补充:
          </el-col>
          <el-col :span="12"> </el-col>
        </el-row>
        <el-row class="elrowmagtop">
          <el-col :span="8">
            备注：
          </el-col>
          <el-col :span="4">
            <el-input
              type="textarea"
              :rows="2"
              v-model="mqInfo.otherSupplement"
            >
            </el-input>
          </el-col>
        </el-row>
      </div>
      <div
        style="width: 20%;
    display: flex;
    justify-content: flex-end;"
      >
        <!-- 右 -->
        <el-button type="primary" @click="recordshistor()" size="mini"
          >历史面签记录</el-button
        >
      </div>
    </div>
    <!-- 按钮 -->
    <div style="width: 95%;margin: 0 auto; display: flex;justify-content: end;">
      <!-- 下 -->
      <el-button type="primary" @click="faceuserinfo()" size="mini"
        >保存</el-button
      >
      <el-button type="primary" @click="initiatevideo()" size="mini"
        >发起视频</el-button
      >
      <el-button type="primary" @click="conclusion()" size="mini"
        >审核结论</el-button
      >
      <el-button type="primary" @click="videoretrieve()" size="mini"
        >视频调阅</el-button
      >
    </div>
    <!-- tab栏 -->
    <div style="padding-top: 10px;overflow: auto;height: 25rem;">
      <el-tabs type="border-card">
        <el-tab-pane v-if="showtabs2">
          <span slot="label">历史贷款信息 </span>

          <el-table
            ref="multipleTable"
            :data="loanlist.list"
            tooltip-effect="dark"
            style="width: 100%; font-size: 10px"
            @row-click="rowClick"
            :header-cell-style="{ textAlign: 'center' }"
            :cell-style="{ textAlign: 'center' }"
            :row-style="tableRowClassName"
          >
            <el-table-column
              :prop="item.prop"
              :label="item.label"
              v-for="(item, index) in loanlist.loanoption"
              :key="index"
              :width="item.width"
            >
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <el-row
            type="flex"
            justify="end"
            align="middle"
            style="height: 60px"
            v-if="loanlist.paging"
          >
            <el-pagination
              background
              @current-change="handleCurrentChange"
              :current-page.sync="loanlist.page.page"
              :page-size="loanlist.page.pageSize"
              layout="total, prev, pager, next"
              :total="loanlist.page.total"
              :small="true"
            >
            </el-pagination>
          </el-row>
        </el-tab-pane>
        <el-tab-pane v-if="showtabs1">
          <span slot="label" v-if="sqrored(tableData.applCde)"
            >额度信息 <i class="el-icon-close" @click="showtabs1 = false"></i>
          </span>
          <span slot="label" v-else
            >申请人信息 <i class="el-icon-close" @click="showtabs1 = false"></i>
          </span>
          <div>
            <b>贷款人信息</b>
            <el-row class="loanrow">
              <el-col class="loancol" :span="8">
                姓名：{{ limitsinfo.custName }}
              </el-col>
              <el-col class="loancol" :span="8">
                证件号码：{{ limitsinfo.idNo }}
              </el-col>
              <el-col class="loancol" :span="8">
                现住房地址：{{ limitsinfo.liveAddr }}
              </el-col>
              <el-col class="loancol" :span="8">
                移动电话：{{ limitsinfo.phoneNo }}
              </el-col>
              <el-col class="loancol" :span="8">
                配偶姓名：{{ limitsinfo.spouseName }}
              </el-col>
              <el-col class="loancol" :span="8">
                配偶电话：{{ limitsinfo.spouseMobile }}
              </el-col>
            </el-row>
          </div>
          <div>
            <b>联系人信息</b>
            <el-table
              ref="multipleTable"
              :data="contact.list"
              tooltip-effect="dark"
              style="width: 100%; font-size: 10px"
              @row-click="rowClick"
              :header-cell-style="{ textAlign: 'center' }"
              :cell-style="{ textAlign: 'center' }"
              :row-style="tableRowClassName"
            >
              <el-table-column
                :prop="item.prop"
                :label="item.label"
                v-for="(item, index) in contact.contactoption"
                :key="index"
                :width="item.width"
              >
                <template slot-scope="scope">
                  <span v-if="item.prop === 'relRelation'">
                    {{ relRelationMap[scope.row[item.prop]] || "未知关系" }}
                  </span>
                  <!-- 其他列 -->
                  <span v-else>{{ scope.row[item.prop] }}</span>
                </template>
              </el-table-column>
            </el-table>
            <!-- 分页 -->
            <el-row
              type="flex"
              justify="end"
              align="middle"
              style="height: 60px"
              v-if="contact.paging"
            >
              <el-pagination
                background
                :current-page.sync="contact.page.page"
                :page-size="contact.page.pageSize"
                layout="total, prev, pager, next"
                :total="contact.page.total"
                :small="true"
              >
              </el-pagination>
            </el-row>
          </div>
          <div>
            <b>担保人信息</b>
            <el-table
              ref="multipleTable"
              :data="guarantor.list"
              tooltip-effect="dark"
              style="width: 100%; font-size: 10px"
              @row-click="rowClick"
              :header-cell-style="{ textAlign: 'center' }"
              :cell-style="{ textAlign: 'center' }"
              :row-style="tableRowClassName"
            >
              <el-table-column
                :prop="item.prop"
                :label="item.label"
                v-for="(item, index) in guarantor.guarantoroption"
                :key="index"
                :width="item.width"
              >
              </el-table-column>
            </el-table>
            <!-- 分页 -->
            <el-row
              type="flex"
              justify="end"
              align="middle"
              style="height: 60px"
              v-if="guarantor.paging"
            >
              <el-pagination
                background
                :current-page.sync="guarantor.page.page"
                :page-size="guarantor.page.pageSize"
                layout="total, prev, pager, next"
                :total="guarantor.page.total"
                :small="true"
              >
              </el-pagination>
            </el-row>
          </div>
        </el-tab-pane>
        <el-tab-pane v-if="showtabs3">
          <span slot="label">
            风险提示 <i class="el-icon-close" @click="showtabs3 = false"></i
          ></span>

          <div class="table-box" v-for="(items, index) in riskList">
            <b>{{ items.label }}</b>
            <!-- <p>{{ items.list }}</p> -->
            <el-table
              ref="multipleTable"
              :data="items.list"
              tooltip-effect="dark"
              style="width: 100%; font-size: 10px"
              @row-click="rowClick"
              :header-cell-style="{ textAlign: 'center' }"
              :cell-style="{ textAlign: 'center' }"
              :row-style="tableRowClassName"
            >
              <el-table-column
                :prop="item.prop"
                :label="item.label"
                v-for="(item, index) in items.option"
                :key="index"
                :width="item.width"
              >
              </el-table-column>
            </el-table>
          </div>

          <!-- 风险提示内容组件 -->
        </el-tab-pane>
        <el-tab-pane v-if="showtabs4" class="carditdiv">
          <span slot="label"
            >征信报告 <i class="el-icon-close" @click="showtabs4 = false"></i
          ></span>

          <div class="carditimg">
            <!-- <img
              style="width: 100%"
              v-for="(d, index) of carditList"
              :src="d.path"
              :key="index"
              @click="openPreview(index)"
            /> -->
            <iframe
              style="width: 100%;height: 300px; border: none;"
              v-for="(d, index) of carditList"
              :src="d.path"
              :key="index"
              @load="onIframeLoad"
            ></iframe>
          </div>
        </el-tab-pane>
        <el-tab-pane v-if="showtabs5" class="carditdiv">
          <span slot="label"
            >影像资料 <i class="el-icon-close" @click="showtabs5 = false"></i
          ></span>
          <customerImageView
            :idNumber="tableData.idNo"
            :sqbh="tableData.applCde"
          ></customerImageView>
        </el-tab-pane>
      </el-tabs>
    </div>
    <!-- 历史记录 -->
    <el-dialog title="历史面签记录" :visible.sync="showrecords">
      <el-table
        ref="multipleTable"
        :data="recordshistorInfo.list"
        tooltip-effect="dark"
        style="width: 100%; font-size: 10px"
        @row-click="rowClick"
        :header-cell-style="{ textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }"
        :row-style="tableRowClassName"
      >
        <el-table-column
          :prop="item.prop"
          :label="item.label"
          v-for="(item, index) in recordshistorInfo.option"
          :key="index"
          :width="item.width"
        >
          <template slot-scope="scope"> 
            <span v-if="item.prop == 'selfFaceSign'">
              <p v-if="scope.row.selfFaceSign == '1'">面签通过</p>
              <p v-if="scope.row.selfFaceSign == '2'">面签不通过</p>
              <p v-if="scope.row.selfFaceSign == '3'">未决项</p>
            </span>

            <span v-else-if="item.prop == 'thdTeleConfirm'">
              <p v-if="scope.row.thdTeleConfirm == '1'">电核一致</p>
              <p v-if="scope.row.thdTeleConfirm == '2'">电核不一致</p>
              <p v-if="scope.row.thdTeleConfirm == '3'">未决项</p>
            </span>

            <span v-else>
              {{ scope.row[item.prop] }}
            </span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-row
        type="flex"
        justify="end"
        align="middle"
        style="height: 60px"
        v-if="recordshistorInfo.paging"
      >
        <el-pagination
          background
          :current-page.sync="recordshistorInfo.page.page"
          :page-size="recordshistorInfo.page.pageSize"
          layout="total, prev, pager, next"
          :total="recordshistorInfo.page.total"
          :small="true"
        >
        </el-pagination>
      </el-row>

      <div slot="footer" class="dialog-footer">
        <el-button @click="showrecords = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 审核结论 -->
    <el-dialog
      title="审核结论"
      :visible.sync="showconclusion"
      @click="dialogVisible = true"
    >
      <div>
        <el-row>
          <el-col :span="8">
            <span style="color:red">*</span> 审核结论:
          </el-col>
          <el-col :span="16">
            <el-radio
              v-model="auditconclusion.approvaResult"
              label="1"
              :disabled="yepornot"
              >通过</el-radio
            >
            <el-radio v-model="auditconclusion.approvaResult" label="2"
              >拒绝</el-radio
            >
            <el-radio v-model="auditconclusion.approvaResult" label="3"
              >打回</el-radio
            >
            <!-- <el-radio v-model="auditconclusion.approvaResult" label="4"
              >取消</el-radio
            > -->
          </el-col>
        </el-row>

        <el-row
          style="margin-top: 20px;"
          v-if="auditconclusion.approvaResult == '2'"
        >
          <el-col :span="8">
            <span style="color:red">*</span> 拒绝原因:
          </el-col>
          <el-col :span="16">
            <el-select
              v-model="jujueselectedValue"
              placeholder="请选择拒绝原因"
            >
              <el-option
                v-for="item in jujueList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-col>
        </el-row>
        <el-row
          style="margin-top: 20px;"
          v-if="auditconclusion.approvaResult == '3'"
        >
          <el-col :span="8">
            <span style="color:red">*</span> 打回原因:
          </el-col>
          <el-col :span="16">
            <el-select
              v-model="dahuiselectedValue"
              placeholder="请选择打回原因"
            >
              <el-option
                v-for="item in dahuiList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-col>
        </el-row>

        <el-row style="margin-top: 20px;">
          <el-col :span="8">
            <span style="color:red">*</span> 内部留言:
          </el-col>
          <el-col :span="16">
            <el-input
              type="textarea"
              :rows="2"
              placeholder="请输入内容"
              v-model="auditconclusion.innerLeaveMessage"
            >
            </el-input>
          </el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="8">
            <span style="color:red">*</span> 外部留言:
          </el-col>
          <el-col :span="16">
            <el-input
              type="textarea"
              :rows="2"
              placeholder="请输入内容"
              v-model="auditconclusion.outLeaveMessage"
            >
            </el-input>
          </el-col>
        </el-row>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button @click="showconclusion = false">取 消</el-button>
        <!-- <el-button type="primary" @click="submitconclusion">提 交</el-button> -->
        <el-button type="primary" @click="opens">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  queryget100001,
  getqueryInfohistorylist,
  getqueryInfohistorylists,
  queryInfoCMIS200028,
  queryfaceuserinfoshjl,
  queryfaceuserinfogq,
  queryfaceuserinfoCMIS100098, //贷款记录
  queryfaceuserinfoCMIS100020, //贷款记录拼审批数据
  queryfaceuserinfoCMIS100031, //电审风险
  queryfaceuserinfoCMIS100023, //征信查询
  getuserid, //获取该客户userid
  getfaceTime //获取该客户就绪状态和就绪时间
} from "@/api/hubeixiaojin/queryInfo";
import customerImageView from "@/components/common/customerImageView";

export default {
  name: "faceuserinfoTab",
  components: {
    customerImageView
  },
  props: ["tableData", "option"],
  data() {
    return {
      relRelationMap: {
        "01": "父母",
        "02": "子女及兄弟姐妹",
        "03": "同事",
        "04": "同学",
        "05": "朋友",
        "99": "其他"
      },
      userfaceTime: false, //客户还没准备好
      jujueselectedValue: "",
      dahuiselectedValue: "",
      jujueList: [
        { value: "非本人申请或不需要", label: "非本人申请或不需要" },
        { value: "贷款用途不符合要求", label: "贷款用途不符合要求" },
        { value: "客户信息存疑", label: "客户信息存疑" },
        { value: "其他面签核实的异常情况", label: "其他面签核实的异常情况" },
        { value: "资料存疑", label: "资料存疑" },
        { value: "综合资质不符", label: "综合资质不符" },
        { value: "不符合产品准入要求", label: "不符合产品准入要求" },
        { value: "外部信息异常", label: "外部信息异常" },
        {
          value: "不能提供审批所需的必要文件",
          label: "不能提供审批所需的必要文件"
        },
        { value: "营销中心要求拒绝", label: "营销中心要求拒绝" }
      ],
      dahuiList: [
        { value: "调查报告填写不全或有误", label: "调查报告填写不全或有误" },
        { value: "征信异常情况未调查说明", label: "征信异常情况未调查说明" },
        { value: "还款能力调查不充分", label: "还款能力调查不充分" },
        { value: "整套材料缺失", label: "整套材料缺失" },
        { value: "贷款必要材料缺失或瑕疵", label: "贷款必要材料缺失或瑕疵" },
        { value: "征信相关材料缺失或瑕疵", label: "征信相关材料缺失或瑕疵" },
        {
          value: "电核无人接听或预约改日面签",
          label: "电核无人接听或预约改日面签"
        },
        {
          value: "个人信息和贷款要素不清楚",
          label: "个人信息和贷款要素不清楚"
        },
        { value: "本人申贷意向不足", label: "本人申贷意向不足" },
        {
          value: "联系人或单位反馈异常信息",
          label: "联系人或单位反馈异常信息"
        },
        { value: "审批要求补充", label: "审批要求补充" },
        { value: "录入信息不一致", label: "录入信息不一致" },
        { value: "相同问题重复退回", label: "相同问题重复退回" },
        { value: "营销中心要求退回", label: "营销中心要求退回" }
      ],
      yepornot: true, //是否能够提交
      showtabs1: true,
      showtabs2: true,
      showtabs3: true,
      showtabs4: true,
      showtabs5: true,
      mqInfo: {
        selfFaceSign: "", //本人面签（必填项）
        selfFaceSignRemark: "", //本人面签（必填项）备注
        thdTeleConfirm: "", //第三方电核（必填项）
        thdTeleConfirmRemark: "", //第三方电核（必填项） 备注
        otherSupplement: "" //其他补充
      },
      radioId: [],
      //历史贷款数据
      loanlist: {
        list: [],
        paging: false,
        page: {
          total: "",
          pageSize: 10,
          page: 1
        },
        loanoption: [
          {
            label: "客户申请编号",
            prop: "applCde"
          },
          {
            label: "客户名称",
            prop: "custName"
          },
          {
            label: "进件通路",
            prop: "docChannel"
          },
          {
            label: "申请日期",
            prop: "applyDt"
          },
          {
            label: "审批金额",
            prop: "apprvAmt"
          },
          {
            label: "申请状态",
            prop: "inSts"
          },
          {
            label: "审批内容",
            prop: "creditLimitReviewNode.appAdvice"
          }
        ]
      },
      //额度信息
      limitsinfo: {},
      //联系人信息
      contact: {
        list: [],
        paging: false,
        page: {
          total: 0,
          pageSize: 10,
          page: 1
        },
        contactoption: [
          {
            label: "姓名",
            prop: "relName"
          },
          {
            label: "手机",
            prop: "relMobile"
          },
          {
            label: "与申请人关系",
            prop: "relRelation"
          },
          {
            label: "联系地址",
            prop: "relAddr"
          },
          {
            label: "单位名称",
            prop: "relEmpName"
          }
        ]
      },
      //担保人信息
      guarantor: {
        list: [],
        paging: false,
        page: {
          total: 0,
          pageSize: 10,
          page: 1
        },
        guarantoroption: [
          {
            label: "担保人流水",
            prop: "idApp"
          },
          {
            label: "申请流水号",
            prop: "IdName"
          },
          {
            label: "协议担保号",
            prop: "idType"
          },
          {
            label: "担保人名称",
            prop: "idContract"
          },
          {
            label: "担保人手机",
            prop: "idContract"
          },
          {
            label: "担保人身份",
            prop: "idContract"
          }
        ]
      },
      //风险提示汇总
      riskList: [
        {
          label: "核心内部风险准入和拦截",
          list: [],
          option: [
            {
              label: "风险规则ID",
              prop: "ruleId"
            },
            {
              label: "风险规则",
              prop: "ruleDesc"
            },
            {
              label: "风险提示",
              prop: "ruleMsg"
            }
          ]
        },
        {
          label: "外部接入风险准入和拦截",
          list: [],
          option: [
            {
              label: "风险规则ID",
              prop: "ruleId"
            },
            {
              label: "风险规则",
              prop: "ruleDesc"
            },
            {
              label: "风险提示",
              prop: "ruleMsg"
            }
          ]
        },
        {
          label: "风险标签",
          list: [],
          option: [
            {
              label: "风险标签编号",
              prop: "riskCde"
            },
            {
              label: "风险描述",
              prop: "riskDesc"
            }
          ]
        },
        {
          label: "风控模型结果集",
          list: [],
          option: [
            {
              label: "匹配类型",
              prop: "matchType"
            },
            {
              label: "风险校验值",
              prop: "matchCheckValue"
            },
            {
              label: "描述",
              prop: "Remark"
            }
          ]
        },
        {
          label: "风控模型匹配结果值",
          list: [],
          option: [
            {
              label: "匹配结果值",
              prop: "autoApprovFg"
            }
          ]
        },
        {
          label: "贷款相关人信息",
          list: [],
          option: [
            {
              label: "申请人类型",
              prop: "apptTyp"
            },
            {
              label: "是否处于黑名单",
              prop: "blackInd"
            },
            {
              label: "公安身份核查",
              prop: "actionsA"
            },
            {
              label: "人行征信",
              prop: "ActionsB"
            }
          ]
        },
        {
          label: "公积金缴存信息",
          list: [],
          option: [
            {
              label: "征信授权码",
              prop: "gjjCode"
            },
            {
              label: "姓名",
              prop: "name"
            },
            {
              label: "身份证号",
              prop: "pId"
            },
            {
              label: "个人公积金账号",
              prop: "pPfid"
            },
            {
              label: "发生地点的行政区划",
              prop: "occAreaCode"
            },
            {
              label: "数据发生机构代码",
              prop: "dataOrgCode"
            },
            {
              label: "公积金中心中文名称",
              prop: "pfcn"
            },
            {
              label: "单位名称",
              prop: "cName"
            },
            {
              label: "单位统一社会信用代码或组织机构",
              prop: "socialCreditCode"
            },
            {
              label: "开户日期",
              prop: "openDate"
            },
            {
              label: "缴至年月",
              prop: "payToTheYear"
            },
            {
              label: "公积金缴存状态",
              prop: "paymentStatus"
            },
            {
              label: "最近一次缴交日期",
              prop: "lastTimePay"
            },
            {
              label: "月缴存额",
              prop: "monthDeposits"
            },
            {
              label: "单位缴存比例",
              prop: "cDepositRatio"
            },
            {
              label: "个人缴存比例",
              prop: "pDepositRatio"
            },
            {
              label: "预留字段",
              prop: "cDepositRatio"
            },
            {
              label: "授权业务编码",
              prop: "authBusiness"
            },
            {
              label: "是否纳入征信报告",
              prop: "ifInCr"
            },
            {
              label: "获取日期",
              prop: "createTime"
            }
          ]
        },
        {
          label: "客户担保人信息",
          list: [],
          option: [
            {
              label: "担保人名称",
              prop: "guaranteeName"
            },
            {
              label: "担保人手机号",
              prop: "guaranteePhone"
            },
            {
              label: "担保人身份证",
              prop: "guaranteeidNo"
            },
            {
              label: "担保人流水号",
              prop: "seqId"
            },
            {
              label: "申请流水号",
              prop: "applSeq"
            },
            {
              label: "申请流水号",
              prop: "guaranteeNo"
            },
            {
              label: "担保结果",
              prop: "guaranteeResult"
            },
            {
              label: "生效状态",
              prop: "effectState"
            },
            {
              label: "协议开始时间",
              prop: "beginTime"
            },
            {
              label: "协议结束日期",
              prop: "endTime"
            },
            {
              label: "工作单位",
              prop: "companyWork"
            },
            {
              label: "邮箱",
              prop: "email"
            },
            {
              label: "省",
              prop: "pro"
            },
            {
              label: "市",
              prop: "city"
            },
            {
              label: "区",
              prop: "area"
            },
            {
              label: "详细地址",
              prop: "address"
            },
            {
              label: "客户经理编号",
              prop: "managerno"
            }
          ]
        },
        {
          label: "收入计算",
          list: [],
          option: [
            {
              label: "核定月收入",
              prop: "monthIncome"
            },
            {
              label: "可支配月收入",
              prop: "monthAbleUseIncome"
            },
            {
              label: "征信月负债",
              prop: "monthDebt"
            }
          ]
        },
        {
          label: "白名单客户分析结果",
          list: [],
          option: [
            {
              label: "是否白名单客户",
              prop: "isWhiteCompanyList"
            },
            {
              label: "可贷额度",
              prop: "pPersonMaxAmt"
            }
          ]
        }
      ],

      //征信信息
      carditList: [],
      //历史面签记录
      showrecords: false,
      recordshistorInfo: {
        list: [],
        paging: false,
        page: {
          total: 100,
          pageSize: 10,
          page: 1
        },
        option: [
          {
            label: "时间",
            prop: "startTime"
          },
          {
            label: "本人面签",
            prop: "selfFaceSign"
          },
          {
            label: "备注",
            prop: "selfFaceSignRemark"
          },
          {
            label: "第三方电核",
            prop: "thdTeleConfirm"
          },
          {
            label: "备注",
            prop: "thdTeleConfirmRemark"
          },
          {
            label: "其他补充",
            prop: "otherSupplement"
          }
        ]
      },
      //审核结论
      showconclusion: false,
      auditconclusion: {
        radio: "",
        internalmessage: "",
        externalmessages: ""
      },
      agentInfo: {
        //当前座席名字和id
        // dispatchingPerson: Constants.Agent.agentName,
        // dispatchingId: Constants.Agent.agentId,
        // //目标座席和id
        // agentId: "",
        // agentName: "",
        // //座席行政组
        // deptGroupName: Constants.Agent.deptGroupName,
        // //行政组code
        // deptGroupCode: Constants.Agent.deptGroupCode,
        // //access_token
        // access_token: Constants.Agent.access_token,
        // //tenantId
        // tenantId: Constants.Agent.tenantId,
        // //orgCode
        // orgCode: Constants.Agent.orgCode
      }, //调单用到的座席信息
      userid: "",
      intervalId: null
    };
  },
  mounted() {
    const sessionStr = sessionStorage.getItem("userInfo");
    const agentUser = JSON.parse(sessionStr);
    this.agentInfo = agentUser.content;
    this.getdsInfo(); //电审信息查询
    this.getdkhistory(); //贷款历史信息
    this.getkhzx(); //征信查询
    this.getuseridinfo(); //userid信息查询
    this.getuserfaceTime(); //拿客户状态
    this.getqueryget100001();
  },
  methods: {
    // 联系人信息
    getqueryget100001() {
      // console.log("获取联系人信息");
      var params = {
        // condition: {
        applSeq: this.tableData.applSeq
        // },
        // sortCol: "id"
      };
      queryget100001(params, this.agentInfo)
        .then(res => {
          // console.log("queryget100001==", res.data);
          if (res.data.retCode === 200) {
            //获取问题列表
            var data = res.data.data.lcApptRelList;
            this.contact.list = data;
            this.contact.page.total = data.length;
          } else {
            window.globalUiKit.notify("提示", "获取联系人信息失败", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },

    showNotification(message) {
      const notification = this.$notify.info({
        title: "提示",
        message: message,
        position: "bottom-right",
        duration: 0 // 不自动关闭
      });

      // 使用 setTimeout 设置 30 秒后关闭通知
      setTimeout(() => {
        notification.close(); // 关闭通知
      }, 30000); // 30000 毫秒 = 30 秒
    },
    //获取客户状态与时间
    getuserfaceTime() {
      if (!this.userfaceTime) {
        this.intervalId = setInterval(() => {
          var params = {
            request: {
              header: {
                // currentBusinessCode: "/api/Approval/faceTime"
                currentBusinessCode: "api/Approval/submit"
              },
              reqData: {
                idNo: this.tableData.idNo
              }
            }
          };
          getfaceTime(params, this.agentInfo)
            .then(res => {
              if (res.data.data.status == "Y") {
                this.showNotification("客户已就绪, 座席请发起视频");
                this.userfaceTime = true; // 客户准备好了
                this.stopPolling();
              } else {
                this.userfaceTime = false; //客户没准备好
              }
            })
            .catch(err => {
              console.log(err);
            });
        }, 5000);
      }
    },
    //清除计数器
    stopPolling() {
      if (this.intervalId) {
        clearInterval(this.intervalId);
      }
    },
    //获取userid
    getuseridinfo() {
      var params = {
        request: {
          header: {
            currentBusinessCode: "/api/user/getSeqNoByIdNo"
          },
          reqData: {
            idNo: this.tableData.idNo
          }
        }
      };

      getuserid(params, this.agentInfo)
        .then(res => {
          if (res.data.retCode === 200) {
            this.userid = res.data.data.seqNo;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },

    //电审风险
    getdsInfo(val) {
      queryfaceuserinfoCMIS100031(this.tableData.applSeq, this.agentInfo)
        .then(res => {
          if (res.data.retCode === 200) {
            // console.log("电审信息=", res.data.data);
            var arrlist = [];
            //顺序添加 第一个 riskRescList

            if (
              res.data.data.riskRescList &&
              res.data.data.riskRescList !== ""
            ) {
              let data = res.data.data.riskRescList;
              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.riskResc]);
              }
            } else {
              arrlist.push([]);
            }

            // console.log("end 一=", arrlist);
            //顺序添加 第二个 outRiskRescList
            // console.log("outRiskRescList=", res.data.data.outRiskRescList);
            if (
              res.data.data.outRiskRescList &&
              res.data.data.outRiskRescList !== ""
            ) {
              let data = res.data.data.outRiskRescList;
              // console.log("二", data);

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data[0]]);
              }
            } else {
              // console.log("二2");
              arrlist.push([]);
            }
            //顺序添加 第三个 riskLabelList

            if (
              res.data.data.riskLabelList &&
              res.data.data.riskLabelList !== ""
            ) {
              let data = res.data.data.riskLabelList;
              // console.log("三");

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.riskLabel]);
              }
            } else {
              arrlist.push([]);
            }
            //顺序添加 第四个 riskModList

            if (res.data.data.riskModList && res.data.data.riskModList !== "") {
              let data = res.data.data.riskModList;
              // console.log("四");

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.riskMod]);
              }
            } else {
              arrlist.push([]);
            }
            //顺序添加 第五个风控模型匹配结果值 riskModMatchList

            if (
              res.data.data.riskModMatchList &&
              res.data.data.riskModMatchList !== ""
            ) {
              let data = res.data.data.riskModMatchList;
              // console.log("五");

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.riskModMatch]);
              }
            } else {
              arrlist.push([]);
            }

            // 贷款相关人信息 apptBlackIndList
            if (
              res.data.data.apptBlackIndList &&
              res.data.data.apptBlackIndList !== ""
            ) {
              let data = res.data.data.apptBlackIndList;
              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.apptBlackInd]);
              }
            } else {
              arrlist.push([]);
            }

            // 公积金缴存信息 provideFundDepositInfoList
            if (
              res.data.data.provideFundDepositInfoList &&
              res.data.data.provideFundDepositInfoList !== ""
            ) {
              let data = res.data.data.provideFundDepositInfoList;
              // console.log("七");

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.provideFundDepositInfo]);
              }
            } else {
              arrlist.push([]);
            }
            //客户担保人 guaranteeInfoList<guaranteeInfo>
            if (
              res.data.data.guaranteeInfoList &&
              res.data.data.guaranteeInfoList !== ""
            ) {
              let data = res.data.data.guaranteeInfoList;

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.guaranteeInfo]);
              }
            } else {
              arrlist.push([]);
            }
            // 收入计算 srjsList<srjs>
            if (res.data.data.srjsList && res.data.data.srjsList !== "") {
              let data = res.data.data.srjsList;
              // console.log("九", data.srjs);

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.srjs]);
              }
            } else {
              arrlist.push([]);
            }
            // 白名单客户分析结果 whiteCompanyList<whiteCompany>
            if (
              res.data.data.whiteCompanyList &&
              res.data.data.whiteCompanyList !== ""
            ) {
              let data = res.data.data.whiteCompanyList;
              // console.log("十");

              if (data.length > 1) {
                arrlist.push(data);
              } else {
                arrlist.push([data.whiteCompany]);
              }
            } else {
              arrlist.push([]);
            }
            //
            console.log("arrlist", arrlist);

            arrlist.forEach((element, index) => {
              this.riskList[index].list = arrlist[index];
            });
            console.log("riskList", this.riskList);

            // this.riskList.forEach(element => {
            //   console.log(
            //     "label==",
            //     element.label + "----list==",
            //     element.list
            //   );
            // });
          } else {
            // console.log(res.msg);
            window.globalUiKit.notify("提示", "未查询到风险信息", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //贷款历史
    getdkhistory() {
      // var params = {
      //   condition: {
      //     //参数位置
      //     submitted: true,
      //     idNo: this.tableData.idNo //证件号码
      //   },
      //   sortCol: "id"
      // };
      queryfaceuserinfoCMIS100098(this.tableData.idNo, this.agentInfo)
        .then(res => {
          // console.log("贷款历史", res.data.data);
          if (res.data.retCode === 200) {
            let resdata = res.data.data.applLoanListDetails;

            this.loanlist.list = resdata; //数据
            this.loanlist.page.total = res.data.data.count; //总笔数
            var sqrzb = resdata[0].lcApplApptList.lcApplAppt || "";
            var sqrxx = resdata[0].lcApptIndivList.lcApptIndiv || "";
            var sqrkz = resdata[0].lcApptExtList.lcApptExt || "";
            //添加申请人信息
            this.limitsinfo = {
              custName: this.tableData.custName || "",
              idNo: this.tableData.idNo || "",
              phoneNo: sqrxx.indivMobile || "",
              liveAddr: sqrxx.liveAddr || "",
              spouseName: sqrkz.spouseName || "",
              spouseMobile: sqrkz.spouseMobile || ""
            };
          } else {
            //添加申请人信息
            this.limitsinfo = {
              custName: this.tableData.custName || "",
              idNo: this.tableData.idNo || ""
            };
            // console.log(res.msg);
            window.globalUiKit.notify("提示", "未查询到面签信息", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //查询征信
    getkhzx() {
      var params = {
        // condition: {
        //参数位置
        // submitted: true,
        idTyp: "20",
        idNo: this.tableData.idNo, //证件号码
        custName: this.tableData.custName
        // },
        // sortCol: "id"
      };
      queryfaceuserinfoCMIS100023(params, this.agentInfo)
        .then(res => {
          // console.log("征信接口返回=", res.data);
          if (res.data.retCode === 200) {
            // console.log("添加数据前=", this.carditList);

            this.carditList.push({
              path: res.data.data.path,
              url: res.data.data.path
            });

            // console.log("渲染征信信息=", this.carditList);
            //   this.tableData.list = res.data.data.listData; //数据
            //   this.tableData.page.total = res.data.data.totalCount; //总笔数
          } else {
            // console.log("征信信息else=", res);
            window.globalUiKit.notify("提示", "未查询到征信信息", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //判断编号确定是申请人还是额度按钮
    sqrored(id) {
      // 确保 id 是数字且非空
      if (typeof id === "string" && id !== "") {
        const firstChar = id[0];

        switch (firstChar) {
          case "1":
            return false;
          case "9":
            return true;
          default:
        }
      } else {
        console.error("传入的 id 必须是有效的数字");
      }
    },

    faceuserinfo() {
      //面签信息保存
      this.mqInfo.id = this.tableData.id;
      this.$emit("faceuserinfosave", this.mqInfo);
    },
    openPreview(index) {
      window.open(this.carditList[index].url);
    },
    onIframeLoad(event) {
      // 可以在这里处理 iframe 加载完成后的逻辑
      // console.log("Iframe loaded:", event);
    },
    goback() {
      this.stopPolling();
      var params = {
        sortCol: "id",
        condition: {
          id: this.tableData.id,
          status: "2"
        } //申请状态
      };

      queryfaceuserinfogq(params, this.agentInfo)
        .then(res => {
          if (res.data.retCode === 200) {
            window.globalUiKit.notify("提示", "面签挂起成功", "info");
            //返回数据搜索页
            this.$emit("goback");
          } else {
            window.globalUiKit.notify("提示", "面签挂起失败", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //返回
    gohome() {
      this.stopPolling();
      this.$emit("goback");
    },

    //额度信息
    limits() {
      this.showtabs1 = true;
    },
    //风险
    riskbtn() {
      this.showtabs3 = true;
    },
    //征信
    creditbtn() {
      this.showtabs4 = true;
    },
    //客户影像资料查看
    imageinfobtn() {
      this.showtabs5 = true;
    },
    //历史面签记录
    recordshistor() {
      // var params = {
      //   sortCol: "id",
      //   condition: {
      //     // status: "0,1,2,3,10,11,12",
      //     // pushStatus: false, //是否查核心。
      //     // faceInterviewId: this.tableData.id
      //     applSeq: this.tableData.applSeq
      //   }
      // };

      // getqueryInfohistorylist(params, this.agentInfo)
      //   .then(res => {
      //     if (res.data.retCode === 200) {
      //       var data = res.data.data.listData;
      //       var list = [];
      //       data.forEach(element => {
      //         list.push({
      //           startTime: element.startTime || "",
      //           selfFaceSign: element.selfFaceSign || "",
      //           selfFaceSignRemark: element.selfFaceSignRemark || "",
      //           thdTeleConfirm: element.thdTeleConfirm || "",
      //           thdTeleConfirmRemark: element.thdTeleConfirmRemark || "",
      //           otherSupplement: element.otherSupplement || ""
      //         });
      //       });
      //       this.recordshistorInfo.list = list; //展示数据
      //       //弹框列表
      //       this.showrecords = true;
      //     } else {
      //       window.globalUiKit.notify("提示", "未查询到面签历史", "info");
      //     }
      //   })
      //   .catch(err => {
      //     console.log(err);
      //   });

      var params = {
        sortCol: "id",
        condition: {
          // status: "0,1,2,3,10,11,12",
          applSeq: this.tableData.applSeq
        }
      };
      getqueryInfohistorylists(params, this.agentInfo)
        .then(res => {
          // console.log("面签历史数据=", res.data.data);
          if (res.data.retCode === 200) {
            var data = res.data.data.listData;
            var datas = [],
              list = [];

            data.forEach(element => {
              element.listSummarys.forEach(el => {
                datas.push(el);
              });
            });

            // console.log("汇总的面签历史==", datas);

            datas.forEach(element => {
              list.push({
                startTime: element.startTime || "",
                selfFaceSign: element.selfFaceSign || "",
                selfFaceSignRemark: element.selfFaceSignRemark || "",
                thdTeleConfirm: element.thdTeleConfirm || "",
                thdTeleConfirmRemark: element.thdTeleConfirmRemark || "",
                otherSupplement: element.otherSupplement || ""
              });
            });
            this.recordshistorInfo.list = list; //展示数据
            //弹框列表
            this.showrecords = true;
          } else {
            window.globalUiKit.notify("提示", "未查询到面签历史", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });

      // getqueryInfohistorylists(params, this.agentInfo)
      //   .then(res => {
      //     console.log("新接口返回历史数据",res);
      //     if (res.data.retCode === 200) {
      //       // var data = res.data.data.listData;
      //       // var list = [];
      //       // data.forEach(element => {
      //       //   list.push({
      //       //     startTime: element.startTime || "",
      //       //     selfFaceSign: element.selfFaceSign || "",
      //       //     selfFaceSignRemark: element.selfFaceSignRemark || "",
      //       //     thdTeleConfirm: element.thdTeleConfirm || "",
      //       //     thdTeleConfirmRemark: element.thdTeleConfirmRemark || "",
      //       //     otherSupplement: element.otherSupplement || ""
      //       //   });
      //       // });
      //       // this.recordshistorInfo.list = list; //展示数据
      //       //弹框列表
      //       this.showrecords = true;
      //     } else {
      //       window.globalUiKit.notify("提示", "未查询到面签历史", "info");
      //     }
      //   })
      //   .catch(err => {
      //     console.log(err);
      //   });
    },
    // 审核结论展示
    conclusion() {
      this.showconclusionInfo();
      this.showconclusion = true;
      this.auditconclusion = {
        approvaResult: "",
        innerLeaveMessage: "",
        outLeaveMessage: ""
      };
    },

    //审核结论获取面签信息
    showconclusionInfo() {
      var params = {
        sortCol: "id",
        condition: {
          status: "0,1,2,3,10,11,12",
          // pushStatus: false, //是否查核心。
          id: this.tableData.id
        }
      };

      queryInfoCMIS200028(params, this.agentInfo)
        .then(res => {
          if (res.data.retCode === 200) {
            var data = res.data.data.listData[0];
            if ((data.selfFaceSign == 1) & (data.thdTeleConfirm == 1)) {
              // console.log("可以选");
              this.yepornot = false;
            } else {
              this.yepornot = true;
              // console.log("不能选");
            }

            // console.log("面签历史", history);

            return history;
          } else {
            window.globalUiKit.notify("提示", "未查询到面签历史", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },

    opens() {
      // console.log("打回==", this.dahuiselectedValue);
      // console.log("拒绝==", this.jujueselectedValue);

      if (this.auditconclusion.approvaResult == "2") {
        if (this.jujueselectedValue == "") {
          return this.$message.error("请选择拒绝原因");
        }
      }
      if (this.auditconclusion.approvaResult == "3") {
        if (this.dahuiselectedValue == "") {
          return this.$message.error("请选择打回原因");
        }
      }
      // console.log("审核结论", this.auditconclusion);
      if (this.auditconclusion.approvaResult === "") {
        return this.$message.error("请选择审核结论");
      }
      if (this.auditconclusion.innerLeaveMessage === "") {
        return this.$message.error("请输入内部留言");
      }
      if (this.auditconclusion.outLeaveMessage === "") {
        return this.$message.error("请输入外部留言");
      }

      this.$confirm("是否确定提交审核结论?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.submitconclusion();
        })
        .catch(() => {
          this.showconclusion();
        });
    },

    // 审核结论提交
    submitconclusion() {
      this.stopPolling();
      this.showconclusion = false;
      this.auditconclusion.id = this.tableData.id;
      this.auditconclusion.applCde = this.tableData.applCde;

      var params = {};
      //区分打回拒绝等
      if (this.auditconclusion.approvaResult == "2") {
        this.auditconclusion.approvaRejectReason = this.jujueselectedValue;
        //拒绝
        params = {
          sortCol: "id",
          ids: [this.auditconclusion.id],
          condition: this.auditconclusion
        };
      } else if (this.auditconclusion.approvaResult == "3") {
        this.auditconclusion.approvaRejectReason = this.dahuiselectedValue;
        params = {
          sortCol: "id",
          ids: [this.auditconclusion.id],
          condition: this.auditconclusion
        };
      } else {
        params = {
          sortCol: "id",
          ids: [this.auditconclusion.id],
          condition: this.auditconclusion
        };
      }

      queryfaceuserinfoshjl(params, this.agentInfo)
        .then(res => {
          if (res.data.retCode === 200) {
            window.globalUiKit.notify("提示", "审核结论提交成功", "info");
            //提交成功后清空原因
            this.dahuiselectedValue = "";
            this.jujueselectedValue = "";
            this.$emit("goback");
          } else {
            window.globalUiKit.notify("提示", "审核结论提交失败", "info");
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //发起视频
    initiatevideo() {
      this.stopPolling();
      // console.log("发起视频userid==", this.userid);
      this.$emit("initiatevideo", this.userid);
    },
    //视频调阅
    videoretrieve() {
      this.stopPolling();
      // console.log("信息页面触发切换到视频调阅页面");
      this.$emit("videoretrieve");
    }
  }
};
</script>

<style>
.headsbtn {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.elrowmagtop {
  margin-top: 20px;
}
.loanrow {
  text-align: center;
  width: 98%;
}
.loancol {
  margin-top: 10px;
}
/* .carditimg {
  width: 90%;
  margin: 0 auto;
} */
/* .carditdiv {
  height: 300px;
  overflow: auto;
} */
</style>
